// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   HostList.java

package org.quickserver.net.client;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

// Referenced classes of package org.quickserver.net.client:
//            Host

public class HostList
{

    public HostList(String name)
    {
        nameMap = new ConcurrentHashMap();
        setName(name);
        setFullList(new ArrayList());
        setActiveList(new ArrayList());
    }

    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("HostList {");
        sb.append("activeList [").append(activeList).append("]");
        sb.append("nameMap [").append(nameMap).append("]");
        sb.append("fullList [").append(fullList).append("]");
        sb.append("}");
        return sb.toString();
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public List getFullList()
    {
        return fullList;
    }

    public void setFullList(List fullList)
    {
        this.fullList = fullList;
    }

    public List getActiveList()
    {
        return activeList;
    }

    public void setActiveList(List activeList)
    {
        this.activeList = activeList;
    }

    public void add(Host host)
    {
        getFullList().add(host);
        if(host.getName() != null)
            nameMap.put(host.getName(), host);
    }

    public void addDefault(Host host)
    {
        getFullList().add(0, host);
        if(host.getName() != null)
            nameMap.put(host.getName(), host);
    }

    public void remove(Host host)
    {
        getFullList().remove(host);
        if(host.getName() != null)
            nameMap.remove(host.getName());
    }

    public Host getHostByName(String name)
    {
        return (Host)nameMap.get(name);
    }

    private String name;
    private List fullList;
    private volatile List activeList;
    private Map nameMap;
}
